package org.zkoss.zktc.unittest;

import org.junit.Assert;
import org.junit.Test;
import org.zkoss.zktc.core.junit.TestCaseBase;
import org.zkoss.zktc.core.widget.Widget;

public class MiscTestCase extends TestCaseBase{

	protected String getTestCaseUrl(){
		return getTestCaseUrl("/unit/misc.zul");
	}
	
	@Test
	public void testCallFunction(){
		navigate(getTestCaseUrl());
		Widget l1 = findWidget("$l1");
		Assert.assertEquals("hi", l1.call("getValue"));
		l1.call("setValue","abc");
		Assert.assertEquals("abc", l1.call("getValue"));
		
		
		Widget cb = findWidget("$ckbox");
		Assert.assertEquals("check me", cb.call("getLabel"));
//		Assert.assertEquals(Boolean.FALSE, cb.call("isDisabled"));//ZK BUG?
		cb.call("setLabel","thanks");
		Assert.assertEquals("thanks", cb.call("getLabel"));
	}
	@Test
	public void testCheckbox(){
		navigate(getTestCaseUrl());
		
		Widget cb = findWidget("$ckbox");
		Assert.assertNotNull(cb);
		Assert.assertEquals("check me", cb.getLabel());
		Assert.assertEquals("zul.wgt.Checkbox", cb.getClassName());
		
		cb.click();
		
		cb = findWidget("$ckbox");
		Assert.assertNotNull(cb);
		Assert.assertEquals("thanks", cb.getLabel());
	}
	
	@Test
	public void testDumpWidget(){
		navigate(getTestCaseUrl());
		
		Widget d1 = findWidget("$d1");
		d1.dump(true);
		d1.dump(false);
	}
	
	@Test
	public void testDumpDom(){
		navigate(getTestCaseUrl());
		
		Widget d1 = findWidget("$d1");
		d1.dumpDom(true);
		d1.dumpDom(false);
	}
	
}
